(function($f) {	$f.extend.custom("myPlugin1", function(self) {

	"use strict";
	
	// plugin info
	this.info = {
		title: "My Plugin 1",
		version: "0.0.1" // major.minor.build
	};

	// external files which are to be loaded during initialization process
	// value of each item here should be 
	// { name: "", file: "", cond: "an optional function that returns true/false for conditional include" }
	// files are loaded in specified order one after another
	// files of following types can be included:
	// JavaScript (*.js), Stylesheets (*.css) and Templates (*.html) and any other type of files which
	// are defined in "dynamicHtmlEndPoints" configuration setting
	this.include = [
		{ name: "jQuery", file: "libs/jquery.js", cond: function() { return !(window.jQuery); } },
		{ name: "lightBoxJS", file: "libs/jquery.lightbox.js" }
	];

	// NOTE: Since jQuery is already loaded with framework, it will process first file in array above
	// but it will not be loaded
	
	// pre-initialization handler
	// called just after plugin instance is created and no features or includes are processed
	// returns (boolean): 
	//	true: if success 
	//	false: if failed
	this.onPreInit = function() { 
		// any initialization goes here, if any
		var isSuccess = true;

		// check if lightbox is available
		var log = "<p><b>onPreInit of (" + self.handle.name + "):</b> ";
		if ($.fn.lightBox) {
			log += "Lightbox is loaded."; 
		} else {
			log += "Lightbox is not loaded."; 
		};

		// load more files by defining them programatically at runtime
		self.include.push({ name: "lightBoxCSS", file: "styles/jquery.lightbox.css" });
		
		// show
		$("#eventsLog").append(log);
		
		// return
		return isSuccess;
	};
	
	// initialization handler
	// called when all includes are processed and features etc. are added
	// returns (boolean): 
	//	true: if success 
	//	false: if failed
	this.onInit = function() { 
		// any initialization goes here, if any
		var isSuccess = true;

		// show which files are processed and loaded and which not
		var log = "<span class='label label-info'>isProcessed</span>";
		log += " Tells if this file was processed by the framework. It might still not be loaded either because of error or if load condition failed. <br />";
		log += "<span class='label label-info'>isLoaded</span>";
		log += " Tells if this file was loaded and there were no errors. <br /><br />";
		log += "<p><b>onInit (of " + self.handle.name + "): </b><br />";
		log += "jQuery: isProcessed = " + (self.include.isProcessed("jQuery") ? "Yes" : "No") + "<br />";
		log += "jQuery: isLoaded = " + (self.include.isLoaded("jQuery") ? "Yes" : "No") + "<br />";
		log += "lightBoxJS: isProcessed = " + (self.include.isProcessed("lightBoxJS") ? "Yes" : "No") + "<br />";
		log += "lightBoxJS: isLoaded = " + (self.include.isLoaded("lightBoxJS") ? "Yes" : "No") + "<br />";
		log += "lightBoxCSS: isProcessed = " + (self.include.isProcessed("lightBoxCSS") ? "Yes" : "No") + "<br />";
		log += "lightBoxCSS: isLoaded = " + (self.include.isLoaded("lightBoxCSS") ? "Yes" : "No") + "<br />";
		
		// show 
		var element = $("#eventsLog");
		element.append(log);
		
		// activate
		if ($.fn.lightBox) {
			$("#lgb").lightBox();
		};
		
		// return
		return isSuccess;
	};	
	
}); }(fluid));
